import uuid

from sqlalchemy import Column, Integer, String, Text
from sqlalchemy.orm import declarative_base, sessionmaker
from database.mysql_utils import MysqlUtils

Base = declarative_base()


class Rpa(Base):
    __tablename__ = 'rpa'
    rpa_id = Column(Integer, primary_key=True)
    rpa_number = Column(String(255))
    rpa_name = Column(String(255))
    rpa_username = Column(String(255))
    rpa_password = Column(String(255))
    data_source = Column(String(255))
    function_introduction = Column(String(255))
    business_process = Column(String(255))
    mac_address = Column(String(255))
    operation_frequency = Column(String(255))
    operating_time = Column(String(255))
    developer = Column(String(255))
    responsible_person = Column(String(255))
    inspection_results = Column(String(255))
    remark = Column(String(255))


Base.metadata.create_all(MysqlUtils.mysql_connect())
Session = sessionmaker(bind=MysqlUtils.mysql_connect())

if __name__ == '__main__':
    session = Session()
    rpa_number = uuid.uuid4()
    rpa_name = "ABA日数据"
    rpa_username = "15291077940"
    rpa_password = "@Crb19991204"
    data_source = "亚马逊后台-aba报告"
    function_introduction = "每日定时从亚马逊后台下载ABA报告，做数据处理，并上传至爱创数据"
    business_process = ""
    mac_address = "00-1F-A1-4C-33-E4"
    operation_frequency = "每日一次"
    operating_time = "17:15:00"
    developer = "陈荣博"
    responsible_person = "陈荣博"
    inspection_results = "pass"
    remark = "正式运行"
    rpa = Rpa(rpa_number=rpa_number, rpa_name=rpa_name, rpa_username=rpa_username, rpa_password=rpa_password,
              data_source=data_source, function_introduction=function_introduction, business_process=business_process,
              mac_address=mac_address, operation_frequency=operation_frequency, operating_time=operating_time,
              developer=developer, responsible_person=responsible_person, inspection_results=inspection_results)
    session.add(rpa)
    session.commit()
